package com.bwie.list.service.impl;

import com.bwie.common.domain.po.Goods;
import com.bwie.common.domain.vo.GoodsVo;
import com.bwie.common.result.Result;
import com.bwie.list.mapper.GoodsMapper;
import com.bwie.list.service.GoodsService;
import com.bwie.list.util.FastUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsMapper goodsMapper;
    @Autowired
    private FastUtil fastUtil;

    /**
     * 查询商品表
     * @return
     */
    @Override
    public List<Goods> findListAll() {
        return goodsMapper.findListAll();
    }

    @Override
    public void add(GoodsVo goods) {
        goodsMapper.add(goods);

//        goodsMapper.addPic(pic);
    }

    @Override
    public Result upload(MultipartFile file) {
        String str="";
        try {
            fastUtil.upload(file);

        }catch (Exception e){
            throw new RuntimeException(e);
        }

        return Result.success("http://43.142.69.250:8888/"+str,"成功");
    }

    @Override
    public void updateup(Integer goodsId, Integer goodsStatus) {
        goodsMapper.updateup(goodsId,goodsStatus);
    }

    @Override
    public void updateset(Integer goodsId, Integer goodsStatus) {
        goodsMapper.updateset(goodsId,goodsStatus);
    }

    @Override
    public List<Goods> findList(String goodsName) {
        return goodsMapper.findList(goodsName);
    }


}
